package nc.bs.pub.action;

import nc.bs.common.projectFAUtils;
import nc.bs.framework.common.NCLocator;
import nc.bs.pub.compiler.AbstractCompiler2;
import nc.itf.pu.m21.IOrderApprove;
import nc.vo.pu.m21.entity.OrderVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.compiler.PfParameterVO;
import nc.vo.pubapp.pub.power.PowerActionEnum;
import nc.vo.scmpub.res.billtype.POBillType;
import nc.vo.uap.pf.PFBusinessException;
import nccloud.vo.scmpub.utils.power.DataPermissionUtil;

public class N_21_UNSAVEBILL extends AbstractCompiler2 {
	public String getCodeRemark() {
		return "  super.m_tmpVo = vo;\n      nc.vo.pu.m21.entity.OrderVO[] vos =\n          (nc.vo.pu.m21.entity.OrderVO[]) this.getVos();\n      Object retValue =\n          nc.bs.framework.common.NCLocator.getInstance()\n              .lookup(nc.itf.pu.m21.IOrderApprove.class)\n              .unSendapprove(vos, this);\n      return retValue;\n";
	}

	public Object runComClass(PfParameterVO vo) throws BusinessException {
		try {
			super.m_tmpVo = vo;
			OrderVO[] vos = (OrderVO[]) ((OrderVO[]) this.getVos());
			if (vo.isCloudEntry) {
				DataPermissionUtil.checkPermission(vos, POBillType.Order.getCode(),
						PowerActionEnum.UNCOMMIT.getActioncode(), "vbillcode");
			}

			//lhw 231128 保存前校验项目 begin
			new projectFAUtils().projectDataApprove("po_order", vos, "unsave");
			//end
			
			Object retValue = ((IOrderApprove) NCLocator.getInstance().lookup(IOrderApprove.class)).unSendapprove(vos,
					this);
			return retValue;
		} catch (Exception var4) {
			if (var4 instanceof BusinessException) {
				throw (BusinessException) var4;
			} else {
				throw new PFBusinessException(var4.getMessage(), var4);
			}
		}
	}
}